import React, { Component } from 'react'
// import qs from 'querystring';
export default class Detail extends Component {
  state={
    detailData:[
      {id:"0",content:"你好，中国"},
      {id:"1",content:"你好，世界"},
      {id:"2",content:"你好，未来的自己"}
    ]
  }
  render() {
    //接收参数   三者要对应  传递参数、声明参数、接收参数
    console.log(this.props)
    //paramas接收参数
    // const {id,title}=this.props.match.params
    //query接收参数
    // const {id,title}=qs.parse(this.props.location.search.slice(1))
    //state接收参数
    const {id,title}=this.props.location.state
    const {detailData} =this.state
    const res=detailData.find(e=>{
      return e.id===id
    })
    return (
      <ul>
        <li>ID:{id}</li>
        <li>TITLE:{title}</li>
        <li>CONTENT:{res.content}</li>
      </ul>
    )
  }
}
